package com.liu.threadPool.myPool;

/**
 * @author LIU
 * @version 1.0
 * @date 2023/8/4 10:30
 * @description: 需求:
 *         自定义线程池练习,这是任务类,需要实现Runnable;
 *         包含任务编号,每一个任务执行时间设计为0.2秒
 */
public class MyTask implements Runnable{
    private Integer id;

    public MyTask(Integer id) {
        this.id = id;
    }

    @Override
    public void run() {
        String threadName = Thread.currentThread().getName();
        System.out.println("线程：" + threadName + "\t即将执行任务：" + id);
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("线程：" + threadName + "\t执行任务完成：" + id);

    }



    @Override
    public String toString() {
        return "MyTask{" +
                "id=" + id +
                '}';
    }

}
